﻿@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
    Layout = "WithoutSiderbar.cshtml";
    IEnumerable<IPublishedContent> searchs = null;
    Markdown md = new Markdown();
    //List<string> allowDocuments = new List<string> { "", "" };

    string keyword = string.Empty;
    if (Request.QueryString["keyword"] != null)
    {
        keyword = Server.UrlDecode(Request.QueryString["keyword"]);
        if (!string.IsNullOrEmpty(keyword))
        {
            searchs = Umbraco.TypedSearch(keyword, false, "ExternalDocumentSearcher").Where(x => x.IsVisible() && x.TemplateId > 0);
        }
    }
}

<div class="search-list">
    <p class="search-title">Search：@keyword</p>

    @if (searchs != null && searchs.Count() > 0)
            {
        <ul>
            @foreach (IPublishedContent item in searchs)
            {
                string content = "";
                if (item.DocumentTypeAlias == "documentationDetail")
                {
                    content = md.Transform(item.GetPropertyValue<string>("documentContent"));
                }
                <li>
                    <h4><a href="@item.Url">@item.Name</a></h4>
                    <div class="time-info">创建于: @item.CreateDate.ToString("yyyy-MM-dd HH:mm:ss") - 最后修改: @item.UpdateDate.ToString("yyyy-MM-dd HH:mm:ss")</div>
                    <div class="result-description">
                        @Umbraco.Truncate(Umbraco.StripHtml(content), 60)
                    </div>
                </li>
            }
        </ul>
    }
    else
    {
        <p class="no-result">没有搜索到相应的内容！</p>
    }
</div>